package com.lx.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lx.bean.CommentExample;
import com.lx.bean.Content;
import com.lx.bean.ContentExample;
import com.lx.dao.ContentMapper;
import jdk.nashorn.internal.runtime.regexp.joni.Regex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContentService {

    @Autowired
    ContentMapper mapper;

    public Content findall(Integer id) {
        return mapper.selectByExamplewhereAll(id);
    }

    public int instercontent(Content content) {
        return mapper.insertSelective(content);
    }

    public List<Content> findhot() {

        PageHelper.startPage(1, 6);
        String sql = "heat" + " DESC";
        ContentExample example = new ContentExample();
        example.setOrderByClause(sql);
        List<Content> contents = mapper.selectByExampleWithBLOBs(example);

        return contents;

    }

    public List<Content> selAll() {
        return mapper.selectByExample(null);
    }

    public List<Content> selByFbid(Integer integer) {
        return mapper.selByFbid(integer);
    }

}
